package 多线程.线程池;

import org.junit.Test;

import java.util.concurrent.*;

/**
 * Description
 *
 * @Author: Heiffeng
 * @Date: 2021/12/19 11:08
 */
public class AbortPolicy策略时抛出异常之后线程池会终止么 {

    @Test
    public void test() throws InterruptedException {

        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(
                1,
                1,
                1,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(1));

        for (int i = 0; i < 5; i++) {
            threadPool.execute(()->{
                System.out.println("hahaha");
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {}
            });
        }

        System.out.println("能执行到这儿吗？");

        new CountDownLatch(1).await();
    }
}
